const arr = [null, null, undefined, undefined, NaN, NaN, Infinity, Infinity, {}, {}, [1], [1], function() { }, function() { },
];

function unique(arr) {
  const map = new Map();
  const res = [];
  for (var i = 0; i < arr.length; i++) {
    if (map.has(arr[i])) {
      map.set(arr[i], true);
    } else {
      map.set(arr[i], false);
      res.push(arr[i]);
    }
  }
  return res;
}

console.log(unique(arr));